using EventBusDemo.Api.Applications.Orders;
using EventBusDemo.Api.Domains.Orders.Services;
using EventBusDemo.EventBus;
using Savorboard.CAP.InMemoryMessageQueue;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<OrderAppService>();
builder.Services.AddScoped<OrderService>();
builder.Services.AddEventBus();
builder.Services.AddMediatR(config =>
{
    config.RegisterServicesFromAssembly(typeof(Program).Assembly);
});
builder.Services.AddCap(config =>
{
    config.UseInMemoryStorage();
    config.UseInMemoryMessageQueue();
});

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthorization();
app.MapControllers();
app.Run();